<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends MY_Luckydog
{
	public function __construct()
	{
		parent::__construct();
		$this->load->model('luckydog/Admin_user_model', 'admin_user');
        $this->load->model('luckydog/Manager_model', 'manager');
	}
    public function index()
    {
        $login_status  = $this->check_login_status();
        if (empty($login_status)){
        	$this->load->view('/luckydog/common/admin_login');
        }else{
            redirect("/luckydog/index");
        }
    }
	/**
	 * 
	 */
	public function login_manager()
	{
		$username = $this->input->post('username', TRUE);
		$password = $this->input->post('password', TRUE);
		$arr_res = $this->admin_user->check_account($username, $password);
		if ($arr_res['status'] == 0){
			$this->input->set_cookie("username",$username,time()+3600*24); 
             echo json_encode(array('code'=>0,'page'=>"index"));
		}else{
		    echo json_encode(array('code'=>-1,'message'=>$arr_res['message']));
		}
	}
    public function logout(){
        session_unset();
		session_destroy();
        $_SESSION['tr_admin_username'] = "";
        $_SESSION['tr_admin_id'] = "";
        $_SESSION['adminUserInfo'] = "";
		redirect(BASEURL.'luckydog/login');
    }
}
/* End of file login.php */
/* Location: ./application/controllers/luckydog/login.php */
